//
//  ReSetPasswordViewController.m
//  SIPphone
//
//  Created by wrt on 15-2-5.
//  Copyright (c) 2015年 wrtsoft. All rights reserved.
//

#import "ReSetPasswordViewController.h"
#import "ReSetPasswordTwoViewController.h"

@interface ReSetPasswordViewController ()

@end

@implementation ReSetPasswordViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[NetPostClass shareNetPostClass] setDelegate:self];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    float systemVersion = iOSValue;
    if (systemVersion >= 7.0)
    {
        self.edgesForExtendedLayout=UIRectEdgeNone;
    }
    self.title = NSLocalizedString(@"password Reset", @"密码重置 Password Reset");
    
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:[NSString stringWithFormat:@" %@",NSLocalizedString(@"return", @"返回 Return")] style:UIBarButtonItemStylePlain target:self action:@selector(returnButtonPressed)];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
}

- (void)returnButtonPressed
{
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)backGroundTouchdown:(id)sender
{
    [self.numberTextField resignFirstResponder];
}
- (IBAction)numberTextfieldEditEnd:(id)sender
{
    [self.numberTextField resignFirstResponder];
}

- (IBAction)nextButtonPressed:(id)sender
{
    if (self.numberTextField.text.length > 0)
    {
        [[NetPostClass shareNetPostClass] postGetCheckCodeWithUserName:self.numberTextField.text];
    }
    else
    {
        self.errorStatusLabel.text = NSLocalizedString(@"please fill out the phone number", @"请将填写手机号 Please fill out the phone number");
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma NetPostDelegateMethod
/**
 *  post数据成功回调
 *
 *  @param comeBackDic 返回来的字典数据
 *  @param tagNumber   post的tag标识
 */
- (void)postSuccessfulWithString:(NSDictionary *)comeBackDic withTag:(int)tagNumber
{
    ReSetPasswordTwoViewController *reSetTwoVC = [[ReSetPasswordTwoViewController alloc] initWithUserName:self.numberTextField.text];
    [self.navigationController pushViewController:reSetTwoVC animated:YES];
}
/**
 *  post失败返回数据
 *
 *  @param faileString 失败的原因
 *  @param tagNumber   post的tag标识
 */
- (void)postFailedWithString:(NSString *)faileString withTag:(int)tagNumber
{
    //post失败返回的失败原因
    self.errorStatusLabel.text = NSLocalizedString(@"send the verification code failed, please check the network before sending", @"发送验证码失败，请检网络后再发送 Send the verification code failed, please check the network before sending");
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
